#pragma once

class GalaxyField;

/*--------------------------------------------------------------------------*/

struct StarSystemDesc
{
	glm::vec3		m_position;
	float			m_strength;
	Color			m_color;
	uint	m_id;
};

/*--------------------------------------------------------------------------*/

class GalaxyField:
	public ICelestial
{
public:
	GalaxyField(const NodeCreation& nc);
	~GalaxyField();

	/*-IRenderableObject--------------------------------------------------------*/
	void				RenderableBinder(uint treeCalcFlags);
	void				RenderableHelper(const uint i, ERenderQuality::Type quality, uint pendingInstances);
	void				OnEnter();
	void				OnLeave();
	bool				CanBeHost();
	CameraDesc			GetChildCameraDesc();
	void				Log();
	/*---ICelestial-------------------------------------------------------------*/
	void				GenerateContent();
	void				DestroyContent();

	virtual void		OnPreCalc(uint arg) override;

	/*--------------------------------------------------------------------------*/

	const glm::vec3&	GetChildPosition(uint id);

private:
	/*--------Specific data-----------------------------------------------------*/
	std::vector<StarSystemDesc>	m_starSystems;
	void				PrepareGalaxyField();
	uint		m_testsPerFrame;
	uint		m_testStartPoint;
	bool				m_searchNearestStar;

	uint		m_numGalaxies;
	GLVertexArray*		m_galaxyFieldVao;
	const Material*		m_galaxyFieldMaterial;
	void				PrepareStars();
	void				DrawStars();
};

